/*
 * Problem.h
 *
 *  Created on: Sep 18, 2012
 *      Author: pedro
 */

#ifndef PROBLEM_H_
#define PROBLEM_H_


#include <iostream>

#include<mpi.h>

#include "Defines.h"
#include "Graph.h"

#define FIX_EDGE 0
#define REMOVE_EDGE 1

#define AVALIABLE 0
#define FIXED 1
#define REMOVED 2

#define ROW 0
#define COLUMN 1

#define CYCLE 0
#define NO_CYCLE 1

using namespace std;
using namespace MPI;

class Problem {
public:

	Problem(int );

	Problem(Problem &);

	Problem(const Problem &);

	virtual ~Problem();

	void addConstraint(int, int, int);

	bool findRemovedRow(int );

	bool findRemovedColumn(int );

	int getRemovedRowsSize();

	int getRemovedColumnsSize();

	bool checkFeasible(int , int );

	int getShiftColumns(int );

	int getCorrespondentFixedColumn(int );

	Graph & getConstraints();

	int getLowerBound();

	void setLowerBound(int );

	void send(int );

	void receive(int );

	void printRemovedColumns();

	void printRemovedRows();

private:

	void insertionSort(int , int );

	bool checkRowIntegrity(int );

	bool checkColumnIntegrity(int );

	bool find(int );

	Graph constraints;
	int * removedRows;
	int * removedColumns;
	int nRemovedRows;
	int nRemovedColumns;
	int lowerBound;

};

#endif /* PROBLEM_H_ */
